<%= javascript_include_tag "prototype" %>
<%= javascript_include_tag "util" %>
<%= javascript_include_tag "calendar" %>
<script>
/*
		function CheckForm(){
			if (document.getElementById("product_serial").value == "") {
				alert("您没有填写品名规格！");
				document.getElementById("product_serial").focus();
				return false;
			}
			if (document.getElementById("product_name").value == "") {
				alert("您没有填写导针规格！");
				document.getElementById("product_name").focus();
				return false;
			}
			return true;
                }
*/
        function checkNull(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value == "")
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function checkNum(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! digCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function checkFloat(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! floatCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function checkPrice(flag, msg_id, obj_id, msg_text){
                if (flag) {
                        if ($(obj_id).value != "" && ! yuanCheck($(obj_id).value))
                        {
                                $(msg_id).innerText = msg_text;
                                $(msg_id).style.display = "block";
                                return false;
                        }
                        else return true;
                }
                else {
                        $(msg_id).style.display = "none";
                }
        }
        function showPicLink(url, picname) {
                if (url && url.length != "") {
                        document.write("<a target='_blank' href='" + url + "'>" + picname + "</a>");
                }
        }

        function CheckForm(){
                return checkNull(true,'id_serial','product_serial','请输入品名规格') 
                                && checkNull(true,'id_name','product_name','请输入导针规格')
                                && checkFloat(true,'id_total_counts','product_total_counts','数量输入错误')
                                //&& checkPrice(true,'id_in_price','product_in_price','价格输入错误') 
                                //&& checkPrice(true,'id_agent_price','product_agent_price','价格输入错误')
                                && checkPrice(true,'id_sale_price','product_sale_price','价格输入错误')
                               // && checkPrice(true,'id_announce_price','product_announce_price','价格输入错误')
                                //&& checkPrice(true,'id_total_counts','product_total_counts','数量输入错误')
                                ;
        }
</script>
<h1>产品管理 - <span id="secondHeading">修改产品信息</span></h1>
<form id="input-form" action="/product/edit_product/12" enctype="multipart/form-data" method="post"><input id="product_id" name="product_id" type="hidden" value="<%=@product.id%>" />
<TABLE border="0" id="INPUT_TABLE">
	<!--<TR title="进货厂家">
		<TD>厂商：</TD>
		<TD><input id="product_factory" name="product_factory" size="30" type="text" value="<%=@product.factory%>" maxlength="20" /></TD>
	</TR>
	<TR title="产品品牌">
		<TD>品牌：</TD>
		<TD><input id="product_brand" name="product_brand" size="30" type="text" value="<%=@product.brand%>" maxlength="20" /></TD>
                </TR>-->
	<TR title="品名规格">
		<TD>品名规格：</TD>
		<TD><input id="product_serial" name="product_serial" readonly="" size="30" type="text" value="<%=@product.serial%>" maxlength="20"  onfocus="checkNull(false,'id_serial')" onblur="checkNull(true,'id_serial',this.id,'请输入品名规格')"/>          <em>*</em><div class="redNsg" id="id_serial" style="display:none;"></div></TD>
	</TR>
	<TR title="导针规格">
		<TD>导针规格：</TD>
		<TD><input id="product_name" name="product_name" readonly="" size="30" type="text" value="<%=@product.name%>" maxlength="20"  onfocus="checkNull(false,'id_name')" onblur="checkNull(true,'id_name',this.id,'请输入导针规格')"/>          <em>*</em><div class="redNsg" id="id_name" style="display:none;"></div></TD>
	</TR>
<TR title="F">
		<TD>F（槽宽）：</TD>
		<TD><input id="product_F" name="product_F" size="30" TYPE="text" value="<%=@product.F%>"  maxlength="20"onfocus="checkFloat(false,'id_product_F')" onblur="checkFloat(true,'id_product_F',this.id,'输入错误')"/>（mm）<div class="redNsg" id="id_product_F" style="display:none;"></div></TD>
	</TR>
	<TR title="B">
		<TD>B（中径）：</TD>
		<TD><input id="product_B" name="product_B" size="30" type="text" value="<%=@product.B%>" maxlength="20"  onfocus="checkFloat(false,'id_product_B')" onblur="checkFloat(true,'id_product_B',this.id,'输入错误')" />（mm）<div class="redNsg" id="id_product_B" style="display:none;"></div></TD>
                </TR>
                <TR title="P">
		<TD>P（脚距）：</TD>
		<TD><input id="product_P" name="product_P" size="30" type="text" value="<%=@product.P%>" maxlength="20"  onfocus="checkFloat(false,'id_product_P')" onblur="checkFloat(true,'id_product_P',this.id,'输入错误')" />（mm）<div class="redNsg" id="id_product_P" style="display:none;"></div></TD>
                </TR>
	<TR title="每个包装可以容纳产品的数量">
		<TD>入库数量：</TD>
		<TD><input id="product_total_counts" name="product_total_counts" readonly='' size="30" type="text" value="<%=@product.total_counts%>" maxlength="20" onfocus="checkNum(false,'id_total_counts')" onblur="checkFloat(true,'id_total_counts',this.id,'数量输入错误')"/>（kpcs）<div class="redNsg" id="id_total_counts" style="display:none;"></div></TD>
	</TR>
	<TR title="货品进入库房日期 格式2006-01-01">
		<TD>入库日期：</TD>
                <TD>
                        <script language=javascript>
                                var bir_Date=new dateSelector('<%= @product.in_date_at %>');
                                bir_Date.inputID='in_date_at';
                                bir_Date.inputName='in_date_at';
                                bir_Date.display();
                        </script>
                </TD>
	</TR>
	<!--<TR title="进货价格">
		<TD>进货价格：</TD>
		<TD><input id="product_in_price" name="product_in_price" size="30" type="text" value="<%=@product.in_price%>" maxlength="20" onfocus="checkPrice(false,'id_in_price')" onblur="checkPrice(true,'id_in_price',this.id,'价格输入错误')"/>（人民币 元）<div class="redNsg" id="id_in_price" style="display:none;"></div></TD>
	</TR>
	<TR title="客户提货价格">
		<TD>代理价格：</TD>
		<TD><input id="product_agent_price" name="product_agent_price" size="30" type="text" value="<%=@product.agent_price%>"  maxlength="20" onfocus="checkPrice(false,'id_agent_price')" onblur="checkPrice(true,'id_agent_price',this.id,'价格输入错误')" />（人民币 元）<div class="redNsg" id="id_agent_price" style="display:none;"></div></TD>
                </TR>-->
	<TR title="建议最低销售价格">
		<TD>单价：</TD>
		<TD><input id="product_sale_price" name="product_sale_price" size="30" type="text" value="<%=@product.sale_price%>" maxlength="20" onfocus="checkPrice(false,'id_sale_price')" onblur="checkPrice(true,'id_sale_price',this.id,'价格输入错误')" />（元）<div class="redNsg" id="id_sale_price" style="display:none;"></div></TD>
	</TR>
	<!--<TR title="媒体：网站 杂志公布的销售价格">
		<TD>媒体价格：</TD>
		<TD><input id="product_announce_price" name="product_announce_price" size="30" type="text" value="<%=@product.announce_price%>" maxlength="20" onfocus="checkPrice(false,'id_announce_price')" onblur="checkPrice(true,'id_announce_price',this.id,'价格输入错误')"/>（人民币 元）<div class="redNsg" id="id_announce_price" style="display:none;"></div></TD>
	</TR>
	<TR title="进货总数量">
		<TD>进货总数量：</TD>
		<TD><input id="product_total_counts" name="product_total_counts" size="30" type="text" readonly="" value="<%=@product.total_counts%>" maxlength="20"  onfocus="checkPrice(false,'id_total_counts')" onblur="checkPrice(true,'id_total_counts',this.id,'数量输入错误')"/>（个/箱）<div class="redNsg" id="id_total_counts" style="display:none;"></div></TD>
	</TR>
        -->
    <TR>
		<TD>状态：</TD>
		<TD><%if @product.state==0%><font color="red">已停用</font><%elsif @product.state==1%><font color="green">正常</font><%end%></TD>
	</TR>
	<TR>
		<TD>图片1：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture1"%>
              <script>showPicLink("<%=url_for_file_column("pp1", "picture") if @pp1%>", "图片链接1");</script>
              <!-- <a target="_blank" href="<%=url_for_file_column("pp1", "picture") if @pp1%>">图片链接1</a> -->
	      </TD>
	</TR>
	<TR>
		<TD>图片2：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture2" %>
              <script>showPicLink("<%=url_for_file_column("pp2", "picture") if @pp2%>", "图片链接2");</script>
	      </TD>
	</TR>
	<TR>
		<TD>图片3：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture3" %>
              <script>showPicLink("<%=url_for_file_column("pp3", "picture") if @pp3%>", "图片链接3");</script>
	      </TD>
	</TR>
	<TR>
		<TD>图片4：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture4" %>
              <script>showPicLink("<%=url_for_file_column("pp4", "picture") if @pp4%>", "图片链接4");</script>
	      </TD>
	</TR>
	<TR>
		<TD>图片5：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture5" %>
              <script>showPicLink("<%=url_for_file_column("pp5", "picture") if @pp5%>", "图片链接5");</script>
	      </TD>
	</TR>
	<TR>
		<TD>图片6：</TD>
		<TD>
	      <%= file_column_field "productPicture", "picture6" %>
              <script>showPicLink("<%=url_for_file_column("pp6", "picture") if @pp6%>", "图片链接6");</script>
	      </TD>
	</TR>
	<TR title="产品参数 等">
		<TD>产品介绍：</TD>
		<TD><textarea cols="50" id="product_argument" name="product_argument" rows="5"><%=@product.argument%></textarea></TD>
	</TR>
	<TR title="其他需要说明的">
		<TD>产品备注：</TD>
		<TD><textarea id="product_memo" name="product_memo" cols="50" rows="5"><%=@product.memo%></textarea></TD>
	</TR>
	<TR>
		<TD colspan="2" align="right">
			<input name="commit" type="submit" value="修改" class="sub" onclick="return CheckForm()"/>&nbsp;OR&nbsp;<input type="reset" value="重新填写" class="cal">
		</TD>
	</TR>
</table>
<p class="note"> <strong class="alert">注意：</strong><br/>
 一、有 <em>*</em> 标记的是必填项。
 </p>
<%=end_form_tag%>
